package src.ee.ioc.smaug.world;

import java.util.logging.*;
import java.io.*;
import src.ee.ioc.smaug.world.evolution.EnvDescription;

/**
 * Overwriting existing XMLLogger to add xsl file to header
 * @author Margarita Spichakova
 *
 */
public class LoggingXMLFormatter extends XMLFormatter {

    /* (non-Javadoc)
     * @see java.util.logging.XMLFormatter#getHead(java.util.logging.Handler)
     */
    public String getHead(Handler h) {

        String encoding = "UTF-8";

        StringBuffer sb = new StringBuffer();
        sb.append("<?xml version=\"1.0\"");
        sb.append(" encoding=\"");
        sb.append(encoding);
        sb.append("\"");
        sb.append(" standalone=\"yes\"?>\n");
        sb.append("<!DOCTYPE log SYSTEM \""+(new File (EnvDescription.loggerdtd).toURI().toString())+"\">\n");
        sb.append("<?xml-stylesheet type=\"text/xsl\" href=\""+(new File (EnvDescription.loggerxsl).toURI().toString())+ "\"?>\n");
        sb.append("<log>\n");

        return sb.toString();
    }

}
